;; host/structure.scm - (c) rohan drape, 2003-2005

(module
 structure mzscheme

(require (lib "defmacro.ss")
	 (lib "pretty.ss"))

;; Must provide 'define-structure' to define a type and bind a
;; constructor for the type, and accessors and mutators for all
;; fields.  The name of the structure is bound to a syntax so that
;; derived types can be made.

(define-syntax define-structure
  (syntax-rules ()
    ((_ name fields)
     (define-struct name fields (make-inspector)))))

;; Generate an s-expression that will construct the structure 's'.

(require (lib "pconvert.ss"))
(constructor-style-printing #t)
(define (structure->constructor s) (print-convert s))
(define (structure-print s) (pretty-print (structure->constructor s)))

(provide (all-defined)))
